import axios from "axios";
import NProgress from "nprogress";
import 'nprogress/nprogress.css'

const instance = axios.create({
    baseURL: "/api",
    timeout: 3000
})

instance.interceptors.request.use(
    function (config) {
        console.log(config)
        // 设置请求头token
        // config.headers.token = "";   
        NProgress.start();
        return config;
    },
    function (error) {
        return Promise.reject(error);
    }
);

instance.interceptors.response.use(
    function (response) {
        NProgress.done();
        return response.data;
    },
    function (error) {
        NProgress.done();
        return Promise.reject(error);
    }
);

export {instance}
